package com.fili.gui.components.table.data;

import com.fili.core.storage.DataItemType;

import javax.swing.table.DefaultTableModel;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Oct 22, 2006
 * Time: 2:14:14 PM
 */
public class DataTableModel extends DefaultTableModel
{
    public int getColumnCount()
    {
        return DataItemType.getNumValues() + 1;
    }

    public int getRowCount()
    {
        return 10;
    }


    public String getColumnName(int column)
    {
        if (column == 0)
            return "Nr. ord";
        else
            return DataItemType.getType(DataItemType.Index.values()[column - 1]).getName();
    }

    public Object getValueAt(int row, int column)
    {
        if (column == 0)
            return row;
        else
        {
            if (getColumnClass(column).equals(Boolean.class))
                return ((column+row)%5>3);
            return 10.0;
        }
    }

    public Class<?> getColumnClass(int columnIndex)
    {

        if (columnIndex == 0)
            return Number.class;

        switch (DataItemType.getType(DataItemType.Index.values()[columnIndex - 1]).getType())
        {
            case DataItemType.TYPE_BOOL:
                return Boolean.class;
            default:
                return Number.class;
        }
    }


    
}
